package com.huang.consumer_mall.web;

import com.huang.consumer_mall.model.Collect;
import com.huang.consumer_mall.service.CollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class CollectColltroller {
    @Autowired
    protected CollectService collectService;


    @PostMapping("/api/collect/findCollectList")
    public List<Collect> findCollectList(@RequestBody Collect collect){
        return collectService.findList(collect);
    }

    @PostMapping("/api/collect/deleteCollect")
    public String deleteById(@RequestBody Collect collect){
        collectService.deleteById(collect);
        return "success";
    }

    @PostMapping("/api/collect/addCollect")
    public String insert(@RequestBody Collect collect){
        Collect collect1 =collectService.find(collect);
        if(collect1 != null){
            return "false";
        }else{
            collectService.insert(collect);
            return "success";
        }
    }
}
